package com.cjm.one.system.controller;

import com.cjm.one.common.result.Result;
import com.cjm.one.model.system.dto.SysDictDataDto;
import com.cjm.one.model.system.entity.SysDictType;
import com.cjm.one.system.service.SysDictTypeService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Slf4j
@Tag(name = "系统字典type表")
@RequestMapping("/admin/system/dict/type")
public class SysDictTypeController {
    @Resource
    private SysDictTypeService sysDictTypeService;

    @PostMapping("/findAll")
    @Operation(summary = "查询所有字典的类型")
    public Result<List<SysDictType>> findAll(@RequestBody SysDictDataDto sysDictDataDto) {
        return  Result.ok(sysDictTypeService.findAll(sysDictDataDto));
    }
    @PostMapping
    @Operation(summary = "新增字典类型")
    public Result<Boolean> save(@RequestBody SysDictType sysDictType) {
        return Result.ok(sysDictTypeService.save(sysDictType));

    }
    @PutMapping
    @Operation(summary = "修改字典类型")
    public Result<Boolean> update(@RequestBody SysDictType sysDictType) {
        return Result.ok(sysDictTypeService.updateById(sysDictType));
    }
    @DeleteMapping
    @Operation(summary = "删除字典类型")
    public Result<Boolean> delete(@RequestBody SysDictDataDto sysDictDataDto) {
        return Result.ok(sysDictTypeService.removeDictTypeById(sysDictDataDto));
    }
    @GetMapping("/{id}")
    @Operation(summary = "根据id查询字典类型")
    public Result<SysDictType> findById(@PathVariable("id") Long id) {
        return Result.ok(sysDictTypeService.getById(id));
    }


}
